import QtQuick 2.0

Canvas {
    id: root
    width: 240; height: 120
    onPaint: {
       var ctx = getContext("2d");

        ctx.lineWidth = 4;
        ctx.strokeStyle = "blue";
        ctx.translate(root.width/2, root.height/2);

        ctx.beginPath();  //开始
        ctx.rect(-20, -20, 40, 40);
        ctx.stroke();

        // rotate coordinate system
        ctx.rotate(Math.PI/4);  //旋转
        ctx.strokeStyle = "green";

        // draw path
        ctx.beginPath();
        ctx.rect(-20, -20, 40, 40);
        ctx.stroke();

    }
}
